/**
 * 
 */
var data = {
    		request: {
				name: "",
			},
			channel: {
				name: ''
			},
			formSave: {
				name: [
			        { required: true, message: '名称不能为空', trigger: 'blur' }
			    ]
			},
			columns: [
				{
                    type: 'selection',
                    width: 60,
                    align: 'center'
                },{
                    title: '频道名称',
                    key: 'name'
                }, {
                    title: '操作',
                    width: 200,
                    key: 'action',
                    render () {
                        return '<i-button type="text" size="small">查看</i-button><i-button type="text" size="small">编辑</i-button>';
                    }
                }
			],
			isShow: false,
			list: []
		};
    var adminContainer = new Vue({
		el: '#container',
		data: function() {
			return data;
		},
		beforeCreate: function(){
			var vm = this;
			vm.$http.post('/channels').then((response) => {
				var res = response.data;
				if(res) {
					vm.list = res;
				} 
			}, function(err) {});
		},
		methods: {
			add: function(){
				this.isShow = true;
			},
			save: function(){
				var vm = this;
				vm.$refs['formSave'].validate((valid) => {
					if(valid){
						vm.$http.post('/erp/article/channel/save', JSON.stringify(vm.channel)).then((response) => {
							var res = response.data;
							if(res.success) {
								vm.$Message.success('保存成功');
							} else {
								vm.$Message.error(res.errorMsg);
							}
						}, function(err) {});
					} else {
						vm.$Message.error("表单验证失败");
					}
				});
			}
		}
	});